import 'dart:convert';

import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:guochaoapp/common/widges/appbar.dart';
import 'package:guochaoapp/controller/shopping/order_detail_controller.dart';
import 'package:guochaoapp/model/order_detail_entity.dart';

import '../../r.dart';

class GCOrderReturnDetailPage extends StatelessWidget {

  OrderDetailData orderDetail;

  @override
  Widget build(BuildContext context) {
    orderDetail = Get.arguments;
    // print(json.encode(orderDetailData));
    return Scaffold(
        appBar: GCAppBar(
          titleText: "退货单",
        ),
        body: _initSubviews());
  }

  _initSubviews() {
    return Column(
      children: [
        SizedBox(height: 10),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text("退货金额:",style: TextStyle(fontSize: 16)),
              Text("${orderDetail.returnPriceTotal}", style: TextStyle(color: Colors.red, fontSize: 16),),
            ],
          ),
        SizedBox(height: 10),
        Expanded(child: ListView.builder(
            itemCount: orderDetail.returnItemList.length,
            itemBuilder: (BuildContext context, int index) {
              return _getListView(index);
            }))
      ],
    );
  }

  _getListView(int index) {
    OrderDetailDataReturnItemList item = orderDetail.returnItemList[index];
    return Container(
      height: ScreenUtil().setSp(60),
      child: Column(children: [
        SizedBox(height: ScreenUtil().setSp(9)),
        Row(
          children: [
            SizedBox(width: ScreenUtil().setSp(15)),
            Container(
                padding: EdgeInsets.only(
                    left: ScreenUtil().setSp(2), right: ScreenUtil().setSp(2)),
                color: Color(0xFF40A8B3),
                child: Text(
                  "${item.brandName}",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: ScreenUtil().setSp(12),
                  ),
                )),
            SizedBox(width: ScreenUtil().setSp(4)),
            Text("${item.spuName}",
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(12),
                )),
            Expanded(child: SizedBox()),
            Opacity(
                opacity: 0.8,
                child: Text(
                  "单价: ￥${item.price}",
                  style: TextStyle(
                    fontSize: ScreenUtil().setSp(12),
                  ),
                )),
            SizedBox(width: ScreenUtil().setSp(10)),
          ],
        ),
        SizedBox(height: ScreenUtil().setSp(8)),
        Row(
          children: [
            SizedBox(width: ScreenUtil().setSp(15)),
            Text("规格:${item.skuSpec}",
                style: TextStyle(
                    fontSize: ScreenUtil().setSp(12),
                    fontWeight: FontWeight.bold)),
            Expanded(child: SizedBox()),
            Opacity(
                opacity: 0.8,
                child: Text(
                  "数量: ${item.num}",
                  style: TextStyle(
                    fontSize: ScreenUtil().setSp(12),
                  ),
                )),
            SizedBox(width: ScreenUtil().setSp(14)),
          ],
        )
      ]),
    );
  }
}
